<?php
defined('IN_YuLin') || exit('NO PERMIT!');

$data = array();

$where 	= " FROM yulin_user_money_log AS ml	LEFT JOIN yulin_user AS u  ON ml.uid = u.id where 1 ";
$tidstr = NoBadStr($_GET['upuid']);
if($tidstr){
	$tidArr = explode(',',$tidstr);
	foreach ($tidArr as $k => $v) {
		$tidArr[$k] = "'".$v."'";
	}
	$where .= " and tid in (".implode(',',$tidArr).")";
}

$username = NoBadStr($_GET['username']);
$username && $where .= " and u.username = '".$username."'";

$lkey = NoBadStr($_GET['lkey']);
$lkey && $where .= " and ml.lkey = '".$lkey."'";

$begintime = NoBadStr($_GET['begintime']);
$begintime && $where .= " and ml.dateline > '".strtotime($_GET['begintime'])."'";

$endtime = NoBadStr($_GET['endtime']);
$endtime && $where .= " and ml.dateline < '".strtotime($_GET['endtime'])."'";

$rows = $db->affected_rows("SELECT ml.id ".$where);
if($rows){
	$page = max(1, intval($_GET['page']));
	$size = 20;
	$url  = "?m=$m&c=$c&a=$a&upuid=".$tidstr."&username=".$username."&lkey=".$lkey."&begintime=".$begintime."&endtime=".$endtime;
	$sql  = "SELECT ml.*,u.username";
	$sql .= $where;
	$sql .=	" ORDER BY ml.id DESC LIMIT ".($page - 1) * $size.",".$size;
	$multi = Multi($url,$page,$rows,$size);

	$data = $db->getall($sql);
}
		

$tpl->display($m.'/'.$c);
